var DataProxy = require("data-proxy");
var Action = require("../apiaction");
var day = 1000*60*60*24;
exports.loginRouter = function(router){

    //登录页面
    router.get(['/','/login'], function(req, res) {
        //var sessionid   = req.cookies.sessionid;
        res.render('login/login',{
            layout  : 'layout-login',
            jscript : 'login/login'
        });
    });


    //登录
    router.post('/doLogin',function(req,res){
        var admin_name = req.param("login_name");
        var admin_password = req.param("password");

        //console.log(admin_name,admin_password);

        var param={};
        param.admin_name=admin_name;
        param.admin_password=admin_password;

        Action.send(req,res,'/admin/login',param,function(res,data){

            //console.log(data);
            var json=JSON.parse(data);

            if(json.code == 0 ){
                res.status(200).send(JSON.stringify(json));
            }else{
                res.status(200).send(data);
            }
        })
    });

}